var MongoClient = require('mongodb').MongoClient;
var DB_CONN_STR = 'mongodb://localhost:27017/runoob';

var insertData = function(db,callback) {
    var collection = db.collection('site');
    var data = [{"name":"北京锐泽黑科技有限公司","url":"www.richerhead.com"},{"name":"北京唯幻科技有限公司","url":"www.weihuan.com"}];
    collection.insert(data, function(err, result) {
        if(err) {
            console.log('Error: '+ err);
            return;
        }
        callback(result);
    });

}

MongoClient.connect(DB_CONN_STR, function(err,db) {
    console.log("连接成功！");
    insertData(db, function(result) {
        console.log(result);
        db.close();
        console.log('Hello Mongo!')
    });
});